package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.saas.domain.dao.EsignSetDao;
import com.xbongbong.saas.domain.dao.EsignTaskDao;
import com.xbongbong.saas.domain.entity.EsignSetEntity;
import com.xbongbong.saas.domain.entity.EsignTaskEntity;
import com.xbongbong.saas.model.EsignSetModel;
import com.xbongbong.saas.model.EsignTaskModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * e签宝任务
 * 创建时间 2020/6/20 2:03 PM
 * 修改时间 2020/6/20 2:03 PM
 * @author chy
 */
@Service("esignTaskModel")
public class EsignTaskModelImpl implements EsignTaskModel {

    @Resource
    private EsignTaskDao esignTaskDao;

    @Override
    public Integer insert(EsignTaskEntity entity) {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        entity.setAddTime(now);
        entity.setDel(DelEnum.NORMAL.getDel());
        return esignTaskDao.insert(entity);
    }

    @Override
    public Integer update(EsignTaskEntity entity) {
        entity.setUpdateTime((long)(DateUtil.getInt()));
        return esignTaskDao.update(entity);
    }

    @Override
    public Integer save(EsignTaskEntity entity) {
        if(entity.getId() == null || Objects.equals(0L, entity.getId())) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public Integer deleteByKey(Long key) {
        return esignTaskDao.deleteByKey(key);
    }

    @Override
    public EsignTaskEntity getByKey(Long key) {
        return esignTaskDao.getByKey(key);
    }

    @Override
    public EsignTaskEntity getByFormId(String corpid, Integer type, Long formId, Long dataId) {
        return esignTaskDao.getByFormId(corpid, type, formId, dataId);
    }

    @Override
    public EsignTaskEntity getByTaskId(String taskId) {
        return esignTaskDao.getByTaskId(taskId);
    }

    @Override
    public List<EsignTaskEntity> findEntitys(Map<String ,Object> param) {
        return esignTaskDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String ,Object>  param) {
        return esignTaskDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }
}
